﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web.UI;

using ProjectBase.Core;

namespace ProjectBase.Mvc
{
    /// <summary>html &lt;IMG&gt; element</summary>
    public class Image : ContentControl<ICoreModel, Image>
    {
        #region members
        #endregion members

        #region constructor
        public Image(string src, string cssClassName = null)
            : base(cssClassName)
        {
            if (src.IsEmpty())
            {
                throw new ArgumentNullException("src", "Image source cannot be null nor empty");
            }
            Src = src;
        }
        #endregion constructor

        #region Render
        public override void RenderControl(HtmlTextWriter writer)
        {
            writer.Write(Environment.NewLine);
            writer.WriteBeginTag(TagName);
            Attributes.Render(writer);
            writer.Write(HtmlTextWriter.SelfClosingTagEnd);
        }
        #endregion Render

        #region Set
        public virtual Image SetAlt(string alt)
        {
            Alt = alt;
            return this;
        }
        #endregion Set

        #region properties
        protected override string TagName
        {
            get { return Tag.Image; }
        }

        public virtual string Alt
        {
            get { return GetAttribute(Attr.Alt); }
            set { SetAttribute(Attr.Alt, value); }
        }

        public string Src
        {
            get { return GetAttribute(Attr.Src); }
            set { SetAttribute(Attr.Src, value); }
        }
        #endregion properties
    }
}